﻿using System;
using System.Web;
using Rabbit.Logic;
using RabbitManage.Code;

namespace RabbitManage.Action
{
    public partial class ShipRuleCityDelete : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies[Constant.CookieName];
            string shopId = cookie.Values[Constant.CookieUid];

            string id = Request["id"];
            if (string.IsNullOrEmpty(id)) return;
            string city = HttpUtility.UrlDecode(id);
            if (city == null)
            {
                return;
            }

            ShipRule rule = RabbitUse.GetShipRuleByShopId(Db.Store, shopId);
            if (rule == null)
            {
                return;
            }

            if (rule.CityRules == null)
            {
                return;
            }

            rule.CityRules.Remove(city);
            RabbitUse.AddShipRule(Db.Store, rule);

            Response.Redirect("~/UI/ShipRuleCityShow.aspx", false);
        }
    }
}